﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

namespace UNSWThink
{
   partial class AboutForm : Form
   {
      private const int Indent = 9;

      public AboutForm()
      {
         InitializeComponent();
         this.Text = String.Format("About {0}", AssemblyTitle);
         this.labelProductName.Text = AssemblyProduct;
         this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
         this.labelCopyright.Text = AssemblyCopyright;
         this.labelCompanyName.Text = AssemblyCompany;
         this.richTextBoxDescription.Text = AssemblyDescription;
      }

      #region Assembly Attribute Accessors

      public string AssemblyTitle
      {
         get
         {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attributes.Length > 0)
            {
               AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
               if (titleAttribute.Title != "")
               {
                  return titleAttribute.Title;
               }
            }
            return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
         }
      }

      public string AssemblyVersion
      {
         get
         {
            return Assembly.GetExecutingAssembly().GetName().Version.ToString();
         }
      }

      public string AssemblyDescription
      {
         get
         {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
            if (attributes.Length == 0)
            {
               return "";
            }
            return ((AssemblyDescriptionAttribute)attributes[0]).Description;
         }
      }

      public string AssemblyProduct
      {
         get
         {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
            if (attributes.Length == 0)
            {
               return "";
            }
            return ((AssemblyProductAttribute)attributes[0]).Product;
         }
      }

      public string AssemblyCopyright
      {
         get
         {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attributes.Length == 0)
            {
               return "";
            }
            return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
         }
      }

      public string AssemblyCompany
      {
         get
         {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
            if (attributes.Length == 0)
            {
               return "";
            }
            return ((AssemblyCompanyAttribute)attributes[0]).Company;
         }
      }
      #endregion

      private void okButton_Click(object sender, EventArgs e)
      {
         this.Close();
      }

      private void richTextBoxDescription_LinkClicked(object sender, LinkClickedEventArgs e)
      {
         System.Diagnostics.Process.Start(e.LinkText);
      }

      private void AboutForm_Load(object sender, EventArgs e)
      {
         this.richTextBoxDescription.SelectedText = "Designed and developed by the Project UNSWThink Team." +
            Environment.NewLine + Environment.NewLine +
            "This application is used for setting up class questions and displaying responses " +
            "submitted by." +
            Environment.NewLine + Environment.NewLine;

         this.richTextBoxDescription.SelectedText = "UNSWThink Team:" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Kenny Jong" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "Adam Letherbarrow" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "Wilson Ong" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectedText = Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "Project Supervisior:" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Richard Buckland" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectedText = Environment.NewLine;

         this.richTextBoxDescription.SelectedText = "UNSWThink is powered by:" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Database: PostgreSQL DBMS (v8.4.0)" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "PostgreSQL Global Development Group" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://www.postgresql.org/" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;

         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Web server: Apache HTTP Server (v2.2.13)" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "Apache Software Foundation" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://httpd.apache.org/" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;

         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Web scripting language: PHP (v5.2.10)" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "The PHP Group" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://www.php.net/" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;

         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Instructor Application: Microsoft .NET Framework (v3.5 SP1)" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "Microsoft" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://msdn.microsoft.com/en-gb/netframework/default.aspx" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;

         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Data providier: Npgsql (v2.0.8)" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "The Npgsql Development Team " + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://npgsql.projects.postgresql.org/" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;

         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Graph Library: ZedGraph (v5.1.5)" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "The ZedGraph Development Team" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://zedgraph.org/" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;

         this.richTextBoxDescription.SelectionBullet = true;
         this.richTextBoxDescription.SelectedText = "Icons: Crystal Project Icons" + Environment.NewLine;
         this.richTextBoxDescription.SelectionBullet = false;
         this.richTextBoxDescription.SelectionIndent = Indent;
         this.richTextBoxDescription.SelectedText = "Everaldo Coelho" + Environment.NewLine;
         this.richTextBoxDescription.SelectedText = "http://yellowicon.com/downloads/page/1" + Environment.NewLine;
         this.richTextBoxDescription.SelectionIndent = 0;
      }
   }
}
